
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
<title>Bootstrap 101 Template</title>

<!-- Bootstrap -->
<link
	href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css"
	rel="stylesheet">

<!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
<!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
<!--[if lt IE 9]>
      <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
<link rel="stylesheet" href="<%=basePath%>statics/css/zIndex.css"
	type="text/css"></link>
<link rel="stylesheet" href="<%=basePath%>statics/css/public.css"
	type="text/css"></link>
</head>
<body>
	<c:import url="head.jsp"></c:import>

	<div class="container">
		<div class="row">
			<div class="col-xs-1 col-sm-3 col-md-4"></div>
			<form class="form-signin  col-xs-10 col-sm-6 col-md-4"
				action="javascript:register();">
				<h2 class="form-signin-heading">注册</h2>
				<div class="input-group">
					<span class="input-group-addon glyphicon glyphicon glyphicon-tag"></span><input
						type="account" id="inputName" name="inputName"
						class="form-control" placeholder="昵称" required autofocus>
				</div>
				<div class="input-group">
					<span class="input-group-addon glyphicon glyphicon-user"></span><input
						type="account" id="inputAccount" name="inputAccount"
						class="form-control" placeholder="账号" required autofocus>
				</div>
				<div class="input-group">
					<span class="input-group-addon glyphicon glyphicon-lock"></span><input
						type="password" id="inputPassword" name="inputPassword"
						class="form-control" placeholder="密码" required autofocus>
				</div>
				<div class="input-group">
					<span class="input-group-addon glyphicon glyphicon-lock"></span><input
						type="password" id="inputPassword2" name="inputPassword2"
						class="form-control" placeholder="确认密码" required autofocus>
				</div>
				<button class="btn btn-lg btn-primary btn-block" type="submit">注册</button>
			</form>
			<div class="col-xs-1 col-sm-3 col-md-4"></div>
		</div>
	</div>
	<!-- /container -->




	<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
	<script
		src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
	<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
	<script
		src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>

	<input type="hidden" id="basePath" value="<%=basePath%>">
	<script type="text/javascript">
		var basePath = $("#basePath").val();
		//登陆
		function register() {
			var inputName = $("#inputName").val();
			var inputAccount = $("#inputAccount").val();
			var inputPassword = $("#inputPassword").val();
			$
					.ajax({
						url : basePath + "register.do",
						type : "POST",
						data : {
							"inputName" : inputName,
							"inputAccount" : inputAccount,
							"inputPassword" : inputPassword
						},
						dataType : "json",
						async : false,
						success : function(jsonMessage) {
							$("#head")
										.append(
											"<div name='message' class='alert alert-danger alert-dismissible zone fade in' role='alert'>"
													+ jsonMessage
													+ "<button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>&times;</span></button>"
													+ "</div>");
							setTimeout(function() {
								/* $("[name=message]").empty();
								$("[name=message]").remove(); */
								$("[name=message]").alert('close');
							}, 3000);
						},
						error : function(xhr, textStatus, errorThrown) {
							alert("注册异常！");
							alert("状态码：" + xhr.status);
							alert("状态:" + xhr.readyState);//当前状态,0-未初始化，1-正在载入，2-已经载入，3-数据进行交互，4-完成。
							alert("错误信息:" + xhr.statusText);
							alert("返回响应信息：" + xhr.responseText);//这里是详细的信息
							alert("请求状态：" + textStatus);
							alert(errorThrown);
						}
					});
		}
	</script>
</body>
</html>